<template>
  <a-spin :spinning="loading">
    <a-tabs v-model:activeKey="resume"  animated style="margin-left: 20px">
      <a-tab-pane tab="锁定需求" key="lockPositionReq" :forceRender="true">
        <j-vxe-table
          :keep-source="true"
          resizable
          ref="resumeEvaluateRecordTableRef"
          :loading="lockPositionReqTable.loading"
          :columns="lockPositionReqTable.columns"
          :dataSource="lockPositionReqTable.dataSource"
          :height="340"
          :disabled="disabled"
          :rowNumber="true"
          :rowSelection="false"
          :toolbar="false"/>
      </a-tab-pane>
    </a-tabs>
  </a-spin>
</template>

<script lang="ts">
  import { defineComponent, ref, reactive, computed } from 'vue';
  import { queryLockPositionReqRecordListByMainId } from '../Resume.api';
  import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  import {lockPositionReqColumns} from '../Resume.data';

  export default defineComponent({
    name: "ResumeForm",
    components:{
      JVxeTable,
    },
    props:{
      formDisabled:{
        type: Boolean,
        default: false
      },
      formData: { type: Object, default: ()=>{} },
      formBpm: { type: Boolean, default: true }
    },
    emits:['success'],
    setup(props) {
      const loading = ref(false);
      const lockPositionReqTable = reactive<Record<string, any>>({
        loading: false,
        columns: lockPositionReqColumns,
        dataSource: []
      });
      
      const activeKey = ref('lockPositionReq');
      const formItemLayout = {
        labelCol: {style: { width: '100px' }},
        wrapperCol: {},
      };

      // 表单禁用
      const disabled = computed(()=>{
        if(props.formBpm === true){
          if(props.formData.disabled === false){
            return false;
          }else{
            return true;
          }
        }
        return props.formDisabled;
      });

      async function edit(row) {
        //子表数据
        const recordDataList = await queryLockPositionReqRecordListByMainId(row['id']);
        lockPositionReqTable.dataSource = [...recordDataList];
      }

      return {
        lockPositionReqTable,
        activeKey,
        loading,
        formItemLayout,
        disabled,
        edit
      }
    }
  });
</script>
